package whf.framework.security.helper;

import whf.framework.entity.decorator.EntityWrapper;
import whf.framework.meta.Meta;
import whf.framework.meta.MetaFactory;
import whf.framework.security.entity.Permission;
import whf.framework.util.Utils;

/**
 * Permission对象的显示封装,用在bo2xml中
 * @author wanghaifeng
 * @create Oct 8, 2006 11:00:44 PM
 * 
 */
public class PermissionDisplayWrapper extends EntityWrapper{
	
	public PermissionDisplayWrapper(Permission perm){
		super(perm);
	}

	/* (non-Javadoc)
	 * @see whf.framework.entity.decorator.IDisplayWrapper#getName()
	 */
	public String getName() {
		Permission permission = (Permission)super.bo;
		try{
			Meta meta = MetaFactory.findByModelClass(Utils.getClassByClassName(permission.getTarget()));
			if(meta != null){
				return meta.getName()+"-"+permission.getName();
			} else {
				return permission.getTarget()+"-"+ permission.getName();
			}
		}catch(Exception e){
			return permission.getName();
		}
	}

}
